/**
 * 演示lodash
 */
// first / last / toUpper / reverse / ecah / includes / find / findIndex
import {
  first,
  last,
  toUpper,
  reverse,
  each,
  includes,
  find,
  findIndex,
} from 'lodash'

const arr: string[] = ['Tom', 'Jerry', 'Lucy', 'Jack']

console.log(first(arr))
console.log(last(arr))
console.log(toUpper(first(arr)))
console.log(reverse(arr))
console.log(arr) // reverse会改变原数组
const res = each(arr, (item, index) => console.log(item, index))
console.log(res) // 返回传入的数组

console.log(includes(arr, 'Tom'))

console.log(find(arr, name => name === 'Lucy')) // Lucy
console.log(find(arr, (name, index) => index === 2)) // Jerry

console.log(findIndex(arr, name => name === 'Lucy')) // 1
console.log(findIndex(arr, (name, index) => index === 2)) // 2

export {}
